#这个脚本用于获取一次鼠标位置，运行后点击鼠标左键即可在终端看到你的鼠标位置，此脚本会自动把鼠标位置 (x,y) 复制到剪贴板。

from pynput import mouse
import pyperclip

def on_click(x, y, button, pressed):
    if pressed and button == mouse.Button.left:
        pos = f"({x},{y})"
        print(f"鼠标位置: {pos}")
        try:
            pyperclip.copy(pos)
            print("已复制到剪贴板")
        except Exception as e:
            print(f"复制失败: {e}")
        return False

if __name__ == "__main__":
    print("请点击鼠标左键获取位置...")
    try:
        with mouse.Listener(on_click=on_click) as listener:
            listener.join()
    except Exception as e:
        print(f"错误: {e}")
